package br.com.cogerh.sidec.view;

import java.util.ArrayList;
import java.util.List;

import br.com.cogerh.sidec.dao.HistoricoDAO;
import br.com.cogerh.sidec.dao.HistoricoImpl;
import br.com.cogerh.sidec.model.Compromisso;
import br.com.cogerh.sidec.model.Historico;
import br.com.cogerh.sidec.util.DAOfactory;

public class HistoricoRN {

	private HistoricoDAO historicoDAO;
	
	public void salvar(Historico historico){
		historicoDAO =  new HistoricoImpl();

		historicoDAO.salvar(historico);
	}
	
	public List<Historico> listar(){
		historicoDAO =  new HistoricoImpl();

		return historicoDAO.listar();
	}

	public List<Historico> listarByCompromisso(Compromisso compromisso){
		historicoDAO =  new HistoricoImpl();

		List<Historico> historicos = new ArrayList<Historico>();
		for (Historico historico : listar()) {
			if(historico.getCompromisso().getNumeroCompromisso().equals(compromisso.getNumeroCompromisso())){
				historicos.add(historico);
			}
		}
		return historicos;
		
	}
	public void excluir(Historico historico){
		historicoDAO =  new HistoricoImpl();

		historicoDAO.excluir(historico);
	}
	
	
}
